---
title: Deploy Kustomizations
sidebar_label: kubectl (kustomize)
---

import FragmentReplaceImageTags from '../../fragments/kubectl-replaceImageTags.mdx';
import FragmentKubectlApplyArgs from '../../fragments/kubectl-options-applyArgs.mdx';
import FragmentKubectlDeleteArgs from '../../fragments/kubectl-options-deleteArgs.mdx';
import FragmentKubectlCmdPath from '../../fragments/kubectl-options-cmdPath.mdx';
import FragmentKubectlKustomize from '../../fragments/kubectl-kustomize.mdx';

To deploy Kustomizations using `kustomize` / `kubectl apply -k`, you need to configure them within the `deployments` section of the `devspace.yaml`.

## Example
```yaml {4}
deployments:
- name: my-deployment
  kubectl:
    kustomize: true
    manifests:
    - my-kustomization/
    - another-kustomization/
```

The above example will be executing during the deployment process as follows:
```bash
kubectl apply -k my-kustomization/
kubectl apply -k another-kustomization/
```

:::warning Kubectl or Kustomize Required
Kustomization deployments require `kubectl` or `kustomize` to be installed. If both are available, DevSpace will use the `kustomize` binary by default.
:::


## Manifests

### `manifests`
The `manifests` option is mandatory and expects an array of paths that point to directories containing Kustomizations.

#### Example: Manifests
```yaml
deployments:
- name: backend
  kubectl:
    kustomize: true
    manifests:
    - my-kustomization/
    - another-kustomization/
```


### `kustomize`

<FragmentKubectlKustomize/>


### `replaceImageTags`

<FragmentReplaceImageTags/>


## Kubectl Options

### `applyArgs`

<FragmentKubectlApplyArgs/>

### `kustomizeArgs`
The `kustomizeArgs` option expects an array of strings stating additional arguments (and flags) that should be used when calling `kustomize build`.

:::info Kustomize Deployments
DevSpace only uses `kustomize build` to render the manifest templates. The actual deployment will be executed using `kubectl apply`.
:::

#### Default Value for `kustomizeArgs`
```yaml
kustomizeArgs: []
```

#### Example: Custom Kustomize Args & Flags
```yaml
deployments:
- name: backend
  kubectl:
    manifests:
    - backend/
    kustomize: true
    kustomizeArgs:
    - "--timeout"
    - "10s"
    - "--grace-period"
    - "30"
```
**Explanation:**  
Deploying the above example would roughly be equivalent to this command:
```bash
kustomize build --timeout=10s --grace-period=30 -f backend/
```

### `deleteArgs`

<FragmentKubectlDeleteArgs/>


### `cmdPath`

<FragmentKubectlCmdPath/>


## General Options

### `name`
The `name` option is required and expects a string to identify this deployment.

#### Example: Deployment Name
```yaml {2}
deployments:
- name: backend
  kubectl:
    manifests:
    - backend/
    - backend-extra/
```

### `namespace`
The `namespace` option is required and expects a string with the namespace used to deploy the manifests.

:::warning
Only use this option if you really need to. Hard-coding the namespace in `devspace.yaml` makes it harder to share the configuration with your colleagues. It is recommended to set the default namespace of the current context instead using:
```bash
devspace use namespace [some-namespace]
```
:::

#### Example: Deployment Namespace
```yaml {3}
deployments:
- name: backend
  namespace: some-namespace
  kubectl:
    manifests:
    - backend/
    - backend-extra/
```

## `disabled`

If true, the deployment will not be deployed, rendered or purged. Can be useful in combination with config expressions or command variables.